﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace Vit.Web.Extensions
{
    public static class DbContextExtensions
    {
        public static void Configuration(this DbContext context, bool enableLazyLoading, bool enableObjectTracking)
        {
            context.Configuration.LazyLoadingEnabled = enableLazyLoading;
            context.Configuration.AutoDetectChangesEnabled = enableObjectTracking;
        }

        public static void EnableProxyCreation(this DbContext context, bool endabled)
        {
            ((System.Data.Entity.Infrastructure.IObjectContextAdapter)context).ObjectContext.ContextOptions.ProxyCreationEnabled = endabled;
        }
    }
}
